package com.trailwalker.activity;

import com.trailwalker.fragment.MainFragment;
import com.trailwalker.javafx.core.activity.Activity;
import com.trailwalker.javafx.core.fragment.FragmentManager;
import com.trailwalker.javafx.utils.style.StyleUtils;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;

/**
 * @author Trailwalker
 * @create 2021-09-05 16:45
 */
public class DetailActivity extends Activity {

    @Override
    public void onCreate() {
        super.onCreate();
        initView();
    }

    private void initView() {
        AnchorPane apRoot = new AnchorPane();
        setContentView(apRoot);
        apRoot.setPrefWidth(500);
        apRoot.setPrefHeight(500);
        StyleUtils.setBackgroundColor(apRoot, "#0000ff");

        Button button = new Button("上一页");
        apRoot.getChildren().add(button);
        button.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                finish();
            }
        });

        AnchorPane ap1 = new AnchorPane();
        apRoot.getChildren().add(ap1);
        ap1.setPrefWidth(400);
        ap1.setPrefHeight(400);
        AnchorPane.setTopAnchor(ap1, 100.0);
        AnchorPane.setLeftAnchor(ap1, 100.0);
        FragmentManager fragmentManager = new FragmentManager(ap1);
        fragmentManager.setMainFragment(MainFragment.class);
        addFragmentManager(fragmentManager);

    }
}
